import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';

import { SafeAreaView } from 'react-navigation';
import Btn from '../components/buttons';
import BaseStyle from '../constants/Style';
import Loadding from '../components/loading';

export default class RadioScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: false,
      text: '',
    };
  }

  render() {
    return (
      <SafeAreaView
        style={[BaseStyle.flex, styles.homebg]}
        forceInset={{ top: 'never' }}>
        <Loadding loading={this.state.loading} text={this.state.text} />

        <View style={styles.container}>
          <Btn
            text={'底部不带文字'}
            onPress={() => {
              this.setState({
                loading: true,
                text: '',
              });
              setTimeout(() => {
                this.setState({ loading: false });
              }, 1000);
            }}
          />
          <Btn
            text={'底部带文字'}
            btnStyle={styles.btnStyle}
            onPress={() => {
              this.setState({
                loading: true,
                text: 'Loading...',
              });
              setTimeout(() => {
                this.setState({ loading: false });
              }, 1000);
            }}
          />
        </View>
      </SafeAreaView>
    );
  }
}

const styles = StyleSheet.create({
  homebg: {
    backgroundColor: '#fff',
  },
  container: {
    ...BaseStyle.flex,
    paddingTop: 20,
  },
  btnStyle: {
    marginTop: 20,
    marginLeft: 0,
    marginRight: 0,
    borderRadius: 0,
  },
});
